package com.xiaoxu.spzx.manager.controller;

import com.xiaoxu.spzx.manager.service.FileUploadService;
import com.xiaoxu.spzx.model.vo.common.Result;
import com.xiaoxu.spzx.model.vo.common.ResultCodeEnum;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/admin/system")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;
    @Operation(summary = "文件上传")
    @PostMapping("/fileUpload")
    public Result fileUpload(MultipartFile file){
        //文件上传 使用MultipleFile

        String fileUrl = fileUploadService.upload(file);//返回minio的文件地址

        return Result.build(fileUrl, ResultCodeEnum.SUCCESS);
    }


}
